package com.wpw.dream.relation;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

public class URLRoute {
	@SuppressWarnings("finally")
	public static String getAbsoluteURL(String baseURI, String relativePath){
	    String abURL=null;
	    try {
	        URI base=new URI(baseURI);//基本网页URI
	        URI abs=base.resolve(relativePath);//解析于上述网页的相对URL，得到绝对URI
	        URL absURL=abs.toURL();//转成URL
	        abURL = absURL.toString();
	    } catch (MalformedURLException e) {
	        e.printStackTrace();
	    } catch (URISyntaxException e) {
	        e.printStackTrace();
	    } finally{
	        return abURL;
	    }
	}
	
	public static void main(String[] args) {
		String baseURI = "http://nyj.ahpc.gov.cn:8090/aa/bb/cc/dd.java";
		String relativePath = "../ahpcmanage/front/info/information_download.jsp?FileName=1002320172219300.pdf&name=安徽省电网发展规划（2017-2021年）.pdf";
		String uri = getAbsoluteURL(baseURI, relativePath);
		System.out.println(uri);
	}

}
